var uid=getcookie("manager_user_uid");
//检验登录权限->
if(uid==null){
alert("cookie异常");
window.location.href="http://localhost:8081/login";}
$("#icon").html("Hello "+uid);
//cookie大礼包
function setcookie(name, value, time) {
        var exp = new Date();
        exp.setTime(exp.getTime() + time * 1);    
        //设置cookie的名称、值、失效时间
        document.cookie = name + "=" + value + ";expires="+ exp.toGMTString();
         
    }
function getcookie(name) {
        //获取当前所有cookie
       var reg = eval("/(?:^|;\\s*)" + name + "=([^=]+)(?:;|$)/");
       return reg.test(document.cookie) ? RegExp.$1 : "";
    }
function deletecookie(name) {
        var exp = new Date();
        exp.setTime(exp.getTime() - 1);
        //获取cookie是否存在
        var value = getcookie(name);
        if (value != null) {
            document.cookie = name + "=" + value + ";expires="+ exp.toUTCString();
        }
   }
  //退出
 function goback(){
	deletecookie("manager_user_uid");
	deletecookie("manager_switch");
 	window.location.href="http://localhost:8081/login";
 }
 //直接使用 user_status写的 show_div obj1为空闲
    function show_div(obj,obj1){
	$("#search_simple_user").hide();
	$("#limit_item").hide();
	$("#unlimit_item").hide();
	$("#"+obj).show();
 }
 //显示用户信息
 function search_simple_user(){
  var search_uid=$("#search_uid").val();
 $("#search_simple_user").hide();
 $("#show_simple_user").show();
  $.ajax({
	   url:"manSearch_api",
	   method:"post",
	   data:{user_uid:search_uid
	   },
	   dataType:"json",
	   success:function(data){
	   var user=data.result;
	   $("#my_name").html("name: "+user.user_name);
	   $("#my_uid").html("uid: "+user.user_uid);
	   $("#my_school_id").html("my_school_id: "+user.user_school_id);
	   $("#my_qq").html("qq: "+user.user_qq);
	   $("#my_tel").html("tel: "+user.user_tel);
	   $("#my_message").html("签名版: "+user.user_message);
	   
	   },
	   error:function(data)
	   { alert("no");}
	   });}
//将物品种类移除白名单   
 function limit_item_submit(){
  var limit_item_kind=$("#limit_item_kind").val();
 
  $.ajax({
	   url:"limit_item_api",
	   method:"post",
	   data:{limit_item_kind:limit_item_kind
	   },
	   dataType:"json",
	   success:function(data){
	  { alert("success");}
	   
	   },
	   error:function(data)
	   { alert("没有该种类");}
	   });}
//将物品种类写入白名单
 function unlimit_item_submit(){
  var unlimit_item_kind=$("#unlimit_item_kind").val();
 
  $.ajax({
	   url:"unlimit_item_api",
	   method:"post",
	   data:{unlimit_item_kind:unlimit_item_kind
	   },
	   dataType:"json",
	   success:function(data){
	  { alert("success");}
	   
	   },
	   error:function(data)
	   { alert("没有该种类");}
	   });}
//限制用户权限
function limit_man_submit(){
  var limit_man=$("#limit_man").val();
 var limit_power=$("#limit_power").val();
  $.ajax({
	   url:"limit_man_api",
	   method:"post",
	   data:{limit_man:limit_man,
	         limit_power:limit_power
	   },
	   dataType:"json",
	   success:function(data){
	  { alert("success");}
	   
	   },
	   error:function(data)
	   { alert("没有该用户");}
	   });}
//解禁用户权限
function unlimit_man_submit(){
  var unlimit_man=$("#unlimit_man").val();
  $.ajax({
	   url:"unlimit_man_api",
	   method:"post",
	   data:{unlimit_man:unlimit_man
	   },
	   dataType:"json",
	   success:function(data){
	  { alert("success");}
	   
	   },
	   error:function(data)
	   { alert("没有该用户");}
	   });} 
//弹出用户黑名单页面 
function show_black(){
 window.open("http://localhost:8081/black","newwindow0","height=650,width=650,top=30,left=350,location=no, status=no,resizable=no"); }
//弹出物品白名单页面
function show_white(){
 window.open("http://localhost:8081/white","newwindow1","height=650,width=650,top=30,left=350,location=no, status=no,resizable=no"); } 
//查询用户信息中的返回按钮
function back(){ 
$("#show_simple_user").hide();
 $("#search_simple_user").show();

}